package com.hskn.hss.module.videoconfig.controller;

import com.hskn.hss.core.annotation.SysLog;
import com.hskn.hss.core.controller.BaseController;
import com.hskn.hss.core.enums.BusinessType;
import com.hskn.hss.entity.AjaxResult;
import com.hskn.hss.module.treemaintain.entity.TreeMaintain;
import com.hskn.hss.module.videoconfig.entity.VideoConfig;
import com.hskn.hss.module.videoconfig.mapper.VideoConfigMapper;
import com.hskn.hss.module.videoconfig.service.IVideoConfigService;
import com.hskn.hss.module.videoconfig.to.VideoConfigTO;
import com.hskn.hss.module.violationCfg.mapper.TlViolationCfgMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 录像设置
 *
 * @author lny
 * @date 2021-11-18
 */
@Api(tags = {"-video_config"}, description = "录像设置")
@RestController
@Slf4j
@RequestMapping("/hss/videoConfig")
public class VideoConfigController extends BaseController {

    @Autowired
    private IVideoConfigService videoConfigService;

    /**
     * 保存
     */
    @SysLog(businessType = BusinessType.INSERT, tableName = "video_config", bean = VideoConfig.class, beanMapper = VideoConfigMapper.class, names = "id")
    @ApiOperation(value = "录像设置保存", notes = "录像设置保存")
    @ApiResponses({@ApiResponse(code = 200, message = "ok")})
    @PostMapping("/save")
    public AjaxResult save(@RequestBody @Validated VideoConfigTO videoConfigTO) {
        try {
            return videoConfigService.save(videoConfigTO);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return AjaxResult.fail(e.getMessage());
        }
    }

    /**
     * 查询
     */
    @ApiOperation(value = "录像设置查询", notes = "录像设置查询")
    @ApiResponses({@ApiResponse(code = 200, message = "ok", response = AjaxResult.class)})
    @PostMapping("/getVideoConfig")
    public AjaxResult getVideoConfig() {
        try {
            return AjaxResult.success(videoConfigService.selectVideoConfig());
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return AjaxResult.fail(e.getMessage());
        }
    }

}
